package com.bmwcarit.barefoot;

import com.bmwcarit.barefoot.matcher.Matcher;
import com.bmwcarit.barefoot.matcher.MatcherCandidate;
import com.bmwcarit.barefoot.matcher.MatcherKState;
import com.bmwcarit.barefoot.matcher.MatcherSample;
import com.bmwcarit.barefoot.roadmap.*;
import com.bmwcarit.barefoot.spatial.Geography;
import com.bmwcarit.barefoot.topology.Dijkstra;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) throws IOException {
        // Load and construct road map
        RoadMap map = Loader.roadmap("config/oberbayern.properties", true).construct();

// Instantiate matcher and state data structure
        Matcher matcher = new Matcher(map, new Dijkstra<Road, RoadPoint>(), new TimePriority(),
                new Geography());

// Input as sample batch (offline) or sample stream (online)
        List<MatcherSample> samples = readSamples();

// Match full sequence of samples
// Create initial (empty) state memory
        MatcherKState state = new MatcherKState();

// Iterate over sequence (stream) of samples
        for (MatcherSample sample : samples) {
            // Execute matcher with single sample and update state memory
            state.update(matcher.execute(state.vector(), state.sample(), sample), sample);

            // Access map matching result: estimate for most recent sample
            MatcherCandidate estimate = state.estimate();
            System.out.println(estimate.point().edge().base().refid()); // OSM id
        }

    }

    private static List<MatcherSample> readSamples() {
        return new ArrayList<>();
    }
}
